﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CygwinPackageManager.Common;

namespace CygwinPackageManager
{
	public partial class AdditionalChangesBox : Form
	{
		public AdditionalChangesBox()
		{
			InitializeComponent();
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.OK;
			Close();
		}

		private IEnumerable<PackageInfo> _packages;
		public IEnumerable<PackageInfo> Packages
		{
			get { return _packages; }
			set
			{
				SetPackages(value);
				_packages = value;
			}
		}

		private void SetPackages(IEnumerable<PackageInfo> packages)
		{
			// TODO: Show additional information of package (e.g. size)
			TreeNode ndInstallation = new TreeNode("To be installed:");
			foreach (PackageInfo package in packages)
			{
				TreeNode ndPackage = new TreeNode()
				{
					Text = package.Name,
					ToolTipText = package.Description
				};

				ndInstallation.Nodes.Add(ndPackage);
			}

			treeView1.Nodes.Add(ndInstallation);
			treeView1.ExpandAll();
		}
	}
}
